package com.yuexunit.finance.system.service;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;

import com.yuexunit.finance.member.entity.lexicon.AuditStateEnum;
import com.yuexunit.finance.system.entity.UserActiveCardInfoEntity;
import com.yuexunit.inject.annotation.Implements;
import com.yuexunit.page.PageCriteria;
import com.yuexunit.page.PageList;
import com.yuexunit.persist.PersistUtil;
import com.yuexunit.persist.annotation.Transactional;


/**
 * @author wenwenlong
 */

@Implements(UserActiveCardInfoService.class)
public class UserActiveCardInfoServiceImpl implements UserActiveCardInfoService {

	@Override
	@Transactional
	public Long createUserActiveCardInfo(UserActiveCardInfoEntity entity) {
		PersistUtil.insert(entity);
		return entity.getActiceCardId();
	}

	@Override
	@Transactional
	public void updateUserActiveCardInfo(UserActiveCardInfoEntity entity) {
		PersistUtil.update(entity);
	}

	@Override
	public UserActiveCardInfoEntity inquireUserActiveCardInfo(Long activeCardId) {
		return PersistUtil.get(UserActiveCardInfoEntity.class, activeCardId);
	}

	@Override
	public PageList<UserActiveCardInfoEntity> inquireUserActiveCardInfoPageList(Integer auditState, PageCriteria page) {
		DetachedCriteria criteria = DetachedCriteria.forClass(UserActiveCardInfoEntity.class);
		if (auditState != null) {
			criteria.add(Restrictions.eq("auditState", AuditStateEnum.valueOf(auditState)));
		}
		return PersistUtil.get(criteria, page);
	}

}
